
import { legacy_createStore as createStore } from 'redux';
const defaultState = {
    num: 100,
    count: 0
};

const reducer = (state = defaultState, actions) => {
    // console.log('reducer');
    if (actions.type == '+') {
        return {
            ...state,
            count: state.count + actions.payload
        }
    }
    if (actions.type == '-') {
        return {
            ...state,
            count: state.count - actions.payload
        }
    }
    return state
}

const store = createStore(
    reducer,
    window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)

export default store